package com.atguigu.srb.core.controller.admin;

import com.atguigu.srb.base.exception.SrbBussinessException;
import com.atguigu.srb.base.result.R;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.TimeUnit;

//测试远程调用
@RestController
@RequestMapping("/admin/rpc")
public class RpcController {

    @GetMapping("/test1")
    public R test1(){
//        try {
//            TimeUnit.SECONDS.sleep(3);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        System.out.println("test1被访问了");
        return R.ok();
    }
    //测试传参
    //路径参数
    @PostMapping("/test2/{id}")
    public R test2(@PathVariable("id")String id) {
        System.out.println("test2被访问了,id:" + id);
        return R.ok();
    }
    //请求参数
    @PostMapping("/test3")
    public R test3(String username  , String password) {
        System.out.println("test3被访问了,username:" + username+ " , password:"+ password);
        return R.ok();
    }
    //请求体
    @PostMapping("/test4")
    public R test4(@RequestBody SrbBussinessException e) {
        System.out.println("test4被访问了,e:" + e);
        return R.ok();
    }
    //pojo入参
    @GetMapping("/test5")
    public R test5(SrbBussinessException e){
        System.out.println("test4被访问了,e:" + e);
        return R.ok();
    }
}
